﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using JoinParty.BLL;
using MySql.Data.MySqlClient;
using ZHDJ.WebPage;

namespace JoinParty.Template
{
    public partial class TJoinStep35 : TemplatePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {


                LoadData();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (PartyOrgMember == null || PartyJoinApplycation == null)
                return;
            WordBusiness.Export(this, palWord, PartyOrgMember.UserName + "--支部大会通过预备党员能否转为正式党员的决议.doc");
        }

        public void LoadData()
        {
            if (PartyOrgMember == null || PartyJoinApplycation == null)
                return;
            litZhibu.Text = GetZhibu();
            litZongzhi.Text = GetZongzhi();
            litDangwei.Text = GetDangwei();
        }

        public string GetZhibu()
        {
            var para = new List<MySqlParameter>
            {
                new MySqlParameter()
                {
                    DbType = DbType.String,
                    ParameterName = "AppllicationID",
                    Value = PartyJoinApplycation.AppllicationID
                }
            };
            string sql =
                @" SELECT MeetingContent FROM tblpartyjoinmeetingex where StandID=(
SELECT StandID FROM tblpartyjoinlinkexample WHERE AppllicationID=?AppllicationID
AND CurrentStepID='JoinStep35' ORDER BY CreateTime DESC LIMIT 0,1
)
";
            object obj = ZHDJ.Data.MySqlHelper.ExecuteScalar(sql, para.ToArray());
            return obj == null ? "" : obj.ToString();
        }

        public string GetZongzhi()
        {
            var para = new List<MySqlParameter>
            {
                new MySqlParameter()
                {
                    DbType = DbType.String,
                    ParameterName = "AppllicationID",
                    Value = PartyJoinApplycation.AppllicationID
                }
            };
            string sql =
                @"select Remark from tblpartyjoinlinkexample where CurrentStepID='JoinStep37' 
and AppllicationID=?AppllicationID ORDER BY CreateTime DESC LIMIT 0,1
";
            object obj = ZHDJ.Data.MySqlHelper.ExecuteScalar(sql, para.ToArray());
            return obj == null ? "" : obj.ToString();
        }

        public string GetDangwei()
        {
            var para = new List<MySqlParameter>
            {
                new MySqlParameter()
                {
                    DbType = DbType.String,
                    ParameterName = "AppllicationID",
                    Value = PartyJoinApplycation.AppllicationID
                }
            };
            string sql =
                @"select ResultsFindings from tblPartyJoinSubmit where AppllicationID=?AppllicationID
";
            object obj = ZHDJ.Data.MySqlHelper.ExecuteScalar(sql, para.ToArray());
            return obj == null ? "" : obj.ToString();
        }
    }
}